package com.hopes.bizz.risk.transfer.bean.dto;

import com.alibaba.fastjson.annotation.JSONField;
import com.hopes.bizz.risk.transfer.constant.RiskConstant;
import com.hopes.bizz.risk.transfer.validation.DateTime;
import com.hopes.bizz.risk.transfer.validation.HidCheck;
import com.hopes.bizz.risk.transfer.validation.Include;
import com.hopes.bizz.risk.transfer.validation.UUID;
import com.hopes.bizz.risk.transfer.validation.group.SeqFour;
import com.hopes.bizz.risk.transfer.validation.group.SeqOne;
import com.hopes.bizz.risk.transfer.validation.group.SeqThree;
import com.hopes.bizz.risk.transfer.validation.group.SeqTwo;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotBlank;

/**
 * @author lyb
 * @version 1.0
 * @description: 隐患信息
 * @date 2024/2/1 16:23
 */

@Data
@EqualsAndHashCode(callSuper = true)
public class RiskDangerInvestigationDto extends RiskBaseLogicDto {

    private static final long serialVersionUID = 8865604373035003607L;

    @NotBlank(message = "危险源编码为空", groups = SeqOne.class)
    private String hazardCode;

    @UUID(allowEmpty = true, message = "管控措施ID不符合UUID正则", groups = SeqOne.class)
    private String riskMeasureId;

    @UUID(allowEmpty = true, message = "隐患排查记录ID不符合UUID正则", groups = SeqOne.class)
    private String checkRecordId;

    @NotBlank(message = "隐患名称为空", groups = SeqOne.class)
    private String dangerName;

    @NotBlank(message = "隐患等级为空", groups = SeqOne.class)
    @Include(item = {"0", "1"}, message = "隐患等级字典项不符合字典枚举,请核对文档<<隐患等级>>字典", groups = SeqTwo.class)
    private String dangerLevel;

    @NotBlank(message = "隐患来源为空", groups = SeqOne.class)
    @Include(item = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}, message = "隐患来源字典项不符合字典枚举,请核对文档<<隐患来源>>字典", groups = SeqTwo.class)
    private String dangerSrc;

    @NotBlank(message = "隐患治理类型为空", groups = SeqOne.class)
    @Include(item = {"0", "1"}, message = "隐患治理类型字典项不符合字典枚举,请核对文档<<隐患治理类型>>字典", groups = SeqTwo.class)
    private String dangerManageType;

    @NotBlank(message = "隐患描述为空", groups = SeqOne.class)
    private String dangerDesc;
    /**
     * 隐患产生原因
     **/
    private String dangerReason;
    /**
     * 控制措施
     **/
    private String controlMeasures;
    /**
     * 资金，单位万元
     **/
    private String cost;
    /**
     * 隐患治理期限
     **/
    @NotBlank(message = "隐患治理期限为空", groups = SeqOne.class)
    @DateTime(message = "<<隐患治理期限>>不符合时间格式", groups = SeqTwo.class)
    private String dangerManageDeadline;

    @NotBlank(message = "隐患状态为空", groups = SeqOne.class)
    @Include(item = {"0", "1", "2", "3", "9"}, message = "隐患状态字典项不符合字典枚举,请核对文档<<隐患状态>>字典", groups = SeqTwo.class)
    private String dangerState;

    @NotBlank(message = "隐患类型为空", groups = SeqOne.class)
    @Include(item = {"1", "2", "3", "4", "5", "6", "7", "8"}, message = "隐患类型字典项不符合字典枚举,请核对文档<<隐患类型>>字典", groups = SeqTwo.class)
    private String hazardDangerType;

    @Include(item = {"0", "1", "2", "3",}, message = "隐患类别字典项不符合字典枚举,请核对文档<<隐患类别>>字典", groups = SeqOne.class)
    private String hazardCategory = "0";

    @NotBlank(message = "登记人姓名为空", groups = SeqOne.class)
    private String registrant;

    @NotBlank(message = "隐患治理期限为空", groups = SeqOne.class)
    @DateTime(message = "<<隐患治理期限>>不符合时间格式", groups = SeqTwo.class)
    private String registTime;

    @NotBlank(message = "整改责任人姓名为空", groups = SeqOne.class)
    private String liablePerson;
    /**
     * 验收人
     **/
    private String checkAcceptPerson;
    /**
     * 验收情况
     **/
    private String checkAcceptComment;
    /**
     * 验收时间
     **/
    @DateTime(allowEmpty = true, message = "<<隐患验收时间>>不符合时间格式", groups = SeqFour.class)
    private String checkAcceptTime;

    @HidCheck(message = "验收人为空", groups = SeqThree.class)
    @JSONField(serialize = false)
    public String getValidaCheckAcceptPerson() {
        return dangerState + RiskConstant.VALIDATOR_JOIN + checkAcceptPerson;
    }

    @HidCheck(message = "验收时间为空", groups = SeqThree.class)
    @JSONField(serialize = false)
    public String getValidaCheckAcceptTime() {
        return dangerState + RiskConstant.VALIDATOR_JOIN + checkAcceptTime;
    }
}
